<template>
    <div class="flex items-center">
        <el-icon :size="20" v-if="modelValue"><component :is="modelValue"></component></el-icon>
        <el-select filterable :modelValue="modelValue" class="ml-2" placeholder="请选择图标" @change="handleSelect">
        <el-option v-for="item in icons" :key="item" :label="item" :value="item">
            <div class="flex items-center justify-between">
                <el-icon>
                    <component :is="item"></component>
                </el-icon>
                <span class="text-gray-400">{{ item }}</span>
            </div>
        </el-option>
    </el-select>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import * as eleicons from '@element-plus/icons-vue';

defineProps({
    "modelValue": {
        type: String,
        default: ""
    }
})

const icons = ref(Object.keys(eleicons))

var emit = defineEmits(["select", "update:modelValue"]);
const handleSelect = (item) => {
    emit("update:modelValue", item);
    emit("selecct", item);
}

</script>